package com.sun.asyncimporttask.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sun.asyncimporttask.entity.ImportTask;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDateTime;

/**
 * 导入任务Mapper接口
 */
@Mapper
public interface ImportTaskMapper extends BaseMapper<ImportTask> {
    @Update("UPDATE import_task SET status = #{status} WHERE task_id = #{taskId}")
    void updateStatus(String taskId, String status);

    @Update("UPDATE import_task SET success_count = success_count + 1 WHERE task_id = #{taskId}")
    void incrementSuccess(String taskId);

    @Update("UPDATE import_task SET fail_count = fail_count + 1 WHERE task_id = #{taskId}")
    void incrementFail(String taskId);

    @Update("UPDATE import_task SET finish_time = #{finishTime} WHERE task_id = #{taskId}")
    void updateFinishTime(String taskId, LocalDateTime finishTime);

    @Update("UPDATE import_task SET total_count = #{totalCount} WHERE task_id = #{taskId}")
    void updateTotalCount(@Param("taskId") String taskId, @Param("totalCount") Integer totalCount);
}